/*
 * @Author: wuqingchun
 * @Date: 2024-10-22 19:22:50
 * @Description: 
 * @LastEditors: wuqingchun
 * @LastEditTime: 2024-10-29 19:47:06
 */
#ifndef __NET_EVENT_SELECT_H__
#define __NET_EVENT_SELECT_H__

#include <cstdint>
#include <map>

#include <sys/select.h>

#include "net_event_handler.h"

class CNetEventSelect : public INetEventHandler
{
public:
    CNetEventSelect();

    virtual int32_t Wait() override final;

    virtual int32_t AddRDEvent(INetTCPConnection* pobjConnection) override final;
    virtual int32_t AddWREvent(INetTCPConnection* pobjConnection) override final;
    virtual void DeleteRDEvent(INetTCPConnection* pobjConnection) override final;
    virtual void DeleteWREvent(INetTCPConnection* pobjConnection) override final;

private:
    fd_set m_stOriginReadSet;
    fd_set m_stOriginWriteSet;
    fd_set m_stTmpReadSet;
    fd_set m_stTmpWriteSet;

    std::map<int, INetTCPConnection*> m_objConnectionMap; // TODO 换成大顶堆
};

#endif //__NET_EVENT_SELECT_H__